#ifndef CORRELATIONBASEDCF_H_
#define CORRELATIONBASEDCF_H_

#include <algorithm>
#include <cmath>
#include <list>
#include <map>
#include <set>

#include "../CFAlgorithm.h"
#include "../../../repository/persistence/DAOFactory.h"
#include "../../../util/Log.h"

using namespace std;

class CorrelationBasedCF: public CFAlgorithm {
private:
	typedef map<pair<int, int> , int> matrix;

	matrix ratings;
	int active_uid;
	double avr_a_user;
	double p_avr_a_user;
	set<int> itens, users;
	DAOFactory* daoFactory;

	void populateRMatrix();
	multimap<string, string> startUpList(int n);
	double pearsonRatingsAverage(const int& uid);
	double ratingsAverage(const int& uid, const int& cid);
	double pearsonCorrelation(const int& uid);
	double calculatePrediction(const int& cid);
public:
	CorrelationBasedCF();
	virtual double predict(int cid);
	virtual multimap<string, string> getTopNList(int n);
	virtual ~CorrelationBasedCF();
};

#endif /* CORRELATIONBASEDCF_H_ */
